package march.test_3_31;

import java.util.Scanner;

public class TestMain4 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextInt();
        }
        System.out.println(returMax(arr, k));
    }

    public static int returMax(int[] nums, int k) {
        int n = nums.length;
        int[][] dp = new int[n + 1][k + 1];
        int[] xarr = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            xarr[i] = xarr[i - 1] ^ nums[i - 1];
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= k; j++) {
                dp[i][j] = dp[i - 1][j];
                for (int p = 0; p < i; p++) {
                    dp[i][j] = Math.max(dp[i][j], dp[p][j - 1] + (xarr[i] ^ xarr[p]));
                }
            }
        }
        return dp[n][k];
    }
}
